﻿using MongoDAO.Configuration;
using MongoDB.Driver;

namespace MongoDAO.Providers
{
    public class MongoCollectionProvider
    {
        private readonly MongoDatabase _database;

        public MongoCollectionProvider() : this(new MongoDatabaseProvider().GetDatabase()) { }

        public MongoCollectionProvider(MongoDatabase database)
        {
            _database = database;
        }

        public MongoCollectionProvider(string connectionStringName)
        {
            _database = new MongoDatabaseProvider(connectionStringName).GetDatabase();
        }

        public MongoCollection<T> GetCollection<T>()
        {
            var collectionName = MongoConfigurationSettings.GetCollectionName<T>();
            return _database.GetCollection<T>(collectionName);
        }

        public MongoCollection GetCollection(string collectionName)
        {
            return _database.GetCollection(collectionName);
        }

    }
}
